<template>
  <a-drawer
    width="45%"
    :title="formTitle"
    :label-col="4"
    :wrapper-col="14"
    :visible="open"
    :body-style="{ height: 'calc(100vh - 100px)', overflow: 'auto' }"
    @close="cancel"
  >
    <a-form-model ref="form" :model="form" :rules="rules" layout="vertical">
      <a-spin :spinning="spinning" :delay="delayTime" tip="Loading...">
        <a-row
          :gutter="32"
          style="width: 70%; margin-left: 15%"
          v-if="type == '廉政手册'"
        >
          <a-col :span="24">
            <a-form-model-item label="文件名称" prop="name">
              <a-input v-model="form.name" placeholder="请输入文件名称" />
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="所属单位" prop="deptId">
              <a-tree-select
                v-model="form.deptId"
                placeholder="请选择所属单位"
                :tree-data="deptOptions"
                tree-default-expand-all
                :replaceFields="{
                  children: 'children',
                  title: 'title',
                  key: 'id',
                  value: 'id',
                }"
                @change="onTreeChange"
              >
              </a-tree-select>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="文件上传：">
              <upload-file @ok="fileOk" />
              <a :href="form.fileUrl" target="_blank">{{ form.fileName }}</a>
            </a-form-model-item>
          </a-col>
        </a-row>
        <a-row
          :gutter="32"
          style="width: 70%; margin-left: 15%"
          v-if="type == '专业书籍'"
        >
          <a-col :span="24">
            <a-form-model-item label="书籍类型" prop="fileType">
              <a-select
                placeholder="请选择籍类型"
                v-model="form.fileType"
                :getPopupContainer="
                  (triggerNode) => {
                    return triggerNode.parentNode || document.body;
                  }
                "
                style="width: 100%"
                allow-clear
              >
                <a-select-option
                  v-for="(d, index) in fileTypeOptions"
                  :key="index"
                  :value="d.dictValue"
                  >{{ d.dictLabel }}</a-select-option
                >
              </a-select>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="文件名称" prop="name">
              <a-input v-model="form.name" placeholder="请输入文件名称" />
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="所属单位" prop="deptId">
              <a-tree-select
                v-model="form.deptId"
                placeholder="请选择所属单位"
                :tree-data="deptOptions"
                tree-default-expand-all
                :replaceFields="{
                  children: 'children',
                  title: 'title',
                  key: 'id',
                  value: 'id',
                }"
                @change="onTreeChange"
              >
              </a-tree-select>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="文件上传：">
              <upload-file @ok="fileOk" />
              <a :href="form.fileUrl" target="_blank">{{ form.fileName }}</a>
            </a-form-model-item>
          </a-col>
        </a-row>
        <a-row
          :gutter="32"
          style="width: 70%; margin-left: 15%"
          v-if="type == '警示案例'"
        >
          <a-col :span="24">
            <a-form-model-item label="年份" prop="times">
              <a-date-picker
                v-model="form.times"
                mode="year"
                :format="yearFormat"
                :open="yearShowOne"
                @openChange="openChangeOne"
                @panelChange="panelChangeOne"
              ></a-date-picker>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="类型" prop="fileType">
              <a-select
                placeholder="请选择类型(类型)"
                v-model="form.fileType"
                :getPopupContainer="
                  (triggerNode) => {
                    return triggerNode.parentNode || document.body;
                  }
                "
                style="width: 100%"
                allow-clear
              >
                <a-select-option
                  v-for="(d, index) in fileTypeOptions"
                  :key="index"
                  :value="d.dictValue"
                  >{{ d.dictLabel }}</a-select-option
                >
              </a-select>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="数量" prop="counts">
              <a-input-number
                v-model="form.counts"
                :min="0"
                style="width: 100%"
              />
            </a-form-model-item>
          </a-col>
        </a-row>
        <a-row :gutter="32" style="width: 70%; margin-left: 15%">
          <a-col :span="24">
            <a-form-model-item label="备注" prop="remark">
              <a-textarea
                v-model="form.remark"
                placeholder="请输入备注"
                :rows="4"
              />
            </a-form-model-item>
          </a-col>
        </a-row>
        <a-row :gutter="32"> </a-row>
      </a-spin>
      <div class="bottom-control">
        <a-space>
          <a-button @click="cancel"> 取消 </a-button>
          <a-button type="primary" @click="submitForm"> 保存 </a-button>
        </a-space>
      </div>
    </a-form-model>
  </a-drawer>
</template>
<script>
import BizLianzhengJiansheEditForm from "./BizLianzhengJiansheForm";
export default {
  ...BizLianzhengJiansheEditForm,
};
</script>
